package com.huluobo.h3kotlinproject.home

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.h3kotlinproject.R
import com.huluobo.h3kotlinproject.data.GoodsBean
import com.huluobo.h3kotlinproject.util.ImageLoader

/**
 *  Created by LC on 2023/10/21.
 *  构造方法:
 *  在kotlin中,一个类后面加上括号就代表是它的构造方法
 *   HomeGoodListAdapter(homeGoodsList: MutableList<HomeGoodsBean>) 就是当前adapter的构造方法
 *   BaseQuickAdapter<HomeGoodsBean, BaseViewHolder>(R.layout.item_home_goods_list, homeGoodsList)
 *   就是被继承的万能适配器的构造方法
 */
class HomeGoodListAdapter(homeGoodsList: MutableList<GoodsBean>) :
    BaseQuickAdapter<GoodsBean, BaseViewHolder>(R.layout.item_home_goods_list, homeGoodsList) {
    override fun convert(holder: BaseViewHolder, item: GoodsBean) {
        holder.setText(R.id.home_item_tv_goods_name, item.goods_desc)
        holder.setText(R.id.home_item_tv_goods_price, "￥${item.goods_default_price}元")
        ImageLoader.loadRoundImage(context, item.goods_default_icon, 20, holder.getView(R.id.home_item_iv_goods_icon))
    }
}